home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / prog / pistol.zip / SESSION0.DOC < prev    next >
Text File  |  1987-08-20  |  5KB  |  194 lines

  1. X> % anything following a " % " is a comment(like this!)
  2. X> % the prompt right now is "X>" as you see:
  3. X> 
  4. X> 
  5. X> 
  6. X> 
  7. X> % to place numbers on the stack one just types them:
  8. X> 
  9. X> 10 20 30
  10. 3X> 
  11. 3X> % notice how the prompt has changed to "3X>", informing
  12. 3X> % us there are three items now waiting on the stack.
  13. 3X> % To see what they actually are, we type:
  14. 3X> 
  15. 3X> STACK
  16. (3)  10  20  30
  17. 3X> 
  18. 3X> % the answer shows the stack with the "top" to the right.
  19. 3X> % The number in parenthesis is telling us that there are
  20. 3X> % indeed three items.
  21. 3X> 
  22. 3X> % to remove the top item:
  23. 3X> 
  24. 3X> DROP
  25. 2X> 
  26. 2X> % note that the prompt tells us that there are two items
  27. 2X> % left.  They are:
  28. 2X> 
  29. 2X> STACK
  30. (2)  10  20
  31. 2X> 
  32. 2X> 
  33. 2X> % suppose we wanted to add these (top) two items on the
  34. 2X> % stack:
  35. 2X> 
  36. 2X> +
  37. 1X> 
  38. 1X> STACK
  39. (1)  30
  40. 1X> 
  41. 1X> % we see that these items have been replaced by "30",
  42. 1X> % our "answer".  Instead of typing STACK we could do:
  43. 1X> 
  44. 1X> =
  45. 30
  46. X> 
  47. X> % the = caused the top of stack to be removed and shown
  48. X> % at the console instead.
  49. X> 
  50. X> % So to perform simple arithmetic like 13 + 24 we could:
  51. X> 
  52. X> 13 24 + =
  53. 37
  54. X> 
  55. X> % indeed our answer should be "37"; since our prompt is
  56. X> % "X>", we have a clean stack (good housekeeping!).
  57. X> 
  58. X> % Here we calculate (3*4) + (5*6) :
  59. X> 
  60. X> 3 4 * 5 6 + =
  61. 11
  62. 1X> % oops, I see I forgot to multiply 5 and 6; their sum has
  63. 1X> % been displayed and the result of multiplying 3 and 4
  64. 1X> % still remains upon the stack:
  65. 1X> 
  66. 1X> STACK
  67. (1)  12
  68. 1X> 
  69. 1X> % lets try completing it correctly this time:
  70. 1X> 
  71. 1X> 5 6 * =
  72. 30
  73. 1X> % oops, I got 5*6, but forgot to add it to the 3*4 part
  74. 1X> % so we can still try again!:
  75. 1X> 
  76. 1X> 5 6 * + =
  77. 42
  78. X> % at last... Here is how I should have done it:
  79. X> 
  80. X> 3 4 * 5 6 * + =
  81. 42
  82. X> % in words: first we calculate 3*4, the result will be
  83. X> % held on the stack. second, we place 5 and 6 on the
  84. X> % stack and calculate their product.  So far, the pair
  85. X> % of products are waiting on the stack.  lastly, we
  86. X> % add (the two products) and display the result.
  87. X> 
  88. X> % calculations are done using RPN, Reverse Polish Notation
  89. X> 
  90. X> % with a little bit of practice, most people become
  91. X> % comfortable with that means of writing problems (it
  92. X> % is the method used on Hewlett-Packard hand calculators
  93. X> 
  94. X> % Admittedly, it takes more practice to read; the prompts
  95. X> % may make the job a little easier!
  96. X> 
  97. X> 
  98. X> % With PISTOL, we don't have to use uppercase for commands
  99. X> % but I shall use uppercase to make it easier for you to
  100. X> % read; but here is an example of using lowercase:
  101. X> 
  102. X> 10 20 30 stack
  103. (3)  10  20  30
  104. 3X> 
  105. 3X> 
  106. 3X> drop stack
  107. (2)  10  20
  108. 2X> 
  109. 2X> 
  110. 2X> drop stack
  111. (1)  10
  112. 1X> 
  113. 1X> 
  114. 1X> drop stack
  115. (0)
  116. X> 
  117. X> drop stack
  118. * STACK UNDERFLOW **** PISTOL 1.3 ***
  119. X> 
  120. X> 
  121. X> % We have demostrated using the STACK command and also a
  122. X> % "new" one, "DROP", whose effect appears to be to throw
  123. X> % away the top item on the stack.
  124. X> 
  125. X> % There are only a few types of error conditions that the
  126. X> % system detects; one of them is when you try to remove
  127. X> % an item from an empty stack.  In this case an "underflow"
  128. X> % occurs, as we see from the "complaint".  An "ABORT" is
  129. X> % performed (signified by *** PISTOL 1.3 ***).  Any
  130. X> % remaining actions on that line (such as "STACK") will
  131. X> % be ignored or bypassed.
  132. X> 
  133. X> 4 5 6 STACK DRP STACK
  134. DRP*** PISTOL 1.3 ***
  135. X> 
  136. X> % Here was another example of a mistake; since "DROP"
  137. X> % was mispelled, PISTOL was unable to figure out the
  138. X> % line typed in.  Thus it carried out none of it.  It
  139. X> % did show what it "stumbled" over.
  140. X> 
  141. X> % I shall try and avoid more errors in this session and
  142. X> % concentrate upon demonstrating various stack related
  143. X> % commands or words:
  144. X> 
  145. X> 
  146. X> 10 20 30 STACK DUP STACK
  147. (3)  10  20  30
  148. (4)  10  20  30  30
  149. 4X> 
  150. 4X> DROP STACK
  151. (3)  10  20  30
  152. 3X> 
  153. 3X> OVER STACK
  154. (4)  10  20  30  20
  155. 4X> 
  156. 4X> 3OVER STACK
  157. (5)  10  20  30  20  10
  158. 5X> 
  159. 5X> 
  160. 5X> DROP DROP STACK
  161. (3)  10  20  30
  162. 3X> 
  163. 3X> 
  164. 3X> DDUP STACK
  165. (5)  10  20  30  20  30
  166. 5X> 
  167. 5X> DROP DROP STACK
  168. (3)  10  20  30
  169. 3X> 
  170. 3X> SWAP
  171. 3X> 
  172. 3X> STACK
  173. (3)  10  30  20
  174. 3X> 
  175. 3X> ABORT
  176. *** PISTOL 1.3 ***
  177. X> 
  178. X> STACK
  179. (0)
  180. X> 
  181. X> % I have demonstrated DUP DROP DDUP OVER 3OVER (there is
  182. X> % also a 2OVER ) STACK (a "utility") and ABORT.
  183. X> % I have mentioned before that when PISTOL detects an
  184. X> % error, it ABORTs, but you can choose to as well. ABORT
  185. X> % will clear the stack.
  186. X> 
  187. X> % This session has lasted long enough.  I shall leave
  188. X> % PISTOL by usng the word "BYE", which is the "proper"
  189. X> % thing to do....
  190. X> 
  191. X> BYE
  192.  
  193.  session and
  194. X> % concentrate upon demonstrating various stac